package com.appwoo.txtws.activity;

import android.app.ProgressDialog;
import android.content.res.Resources;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;
import com.appwoo.txtws.adapter.ListViewCreator;
import com.appwoo.txtws.adapter.Page;
import com.appwoo.txtws.adapter.SimpleListAdapter;
import com.appwoo.txtws.app.App;
import com.appwoo.txtws.app.AppActivity;
import com.appwoo.txtws.bean.AutoSoftInfo;
import com.appwoo.txtws.bean.StateBean;
import com.appwoo.txtws.component.Global;
import com.appwoo.txtws.component.RqSP;
import com.appwoo.txtws.service.RecomSoftServer;
import com.appwoo.txtws.wheel.widget.PageListView;
import com.appwoo.txtws.wheel.widget.PageListView.OnRefreshListener;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class RecomedActivity extends AppActivity
{
  private SimpleListAdapter<AutoSoftInfo> adapter;
  private StateBean bean = new StateBean();
  private boolean blDataTask = false;
  private Button btnCurrent;
  private ProgressDialog dialog = null;
  private List<AutoSoftInfo> events;
  private Boolean isFoot = Boolean.valueOf(false);
  private int isHot = 1;
  private Boolean isSDCard = Boolean.valueOf(false);
  private PageListView lvList;
  private Page<AutoSoftInfo> page = new Page();
  private String softid = "";

  private void initView()
  {
    this.isSDCard = Boolean.valueOf(Global.isSDCard());
    this.lvList = ((PageListView)findViewById(2131492985));
    this.page = new Page();
    this.adapter = new SimpleListAdapter(this.page.getEntries(), new ListViewCreator()
    {
      public View createView(final AutoSoftInfo paramAnonymousAutoSoftInfo, View paramAnonymousView, int paramAnonymousInt)
      {
        if (paramAnonymousView == null)
          paramAnonymousView = App.getLayoutInflater().inflate(2130903122, null);
        ((TextView)paramAnonymousView.findViewById(2131493155)).setText(paramAnonymousAutoSoftInfo.getAsname());
        ((TextView)paramAnonymousView.findViewById(2131493160)).setText(paramAnonymousAutoSoftInfo.getSoftSize());
        ((TextView)paramAnonymousView.findViewById(2131493158)).setText(paramAnonymousAutoSoftInfo.getDesc());
        ImageView localImageView = (ImageView)paramAnonymousView.findViewById(2131493154);
        RecomedActivity.this.loadLogoImage(localImageView, paramAnonymousAutoSoftInfo.getAdicon(), RecomedActivity.this.isSDCard);
        if (paramAnonymousAutoSoftInfo.getIsRecd() == 1)
          ((ImageView)paramAnonymousView.findViewById(2131493159)).setVisibility(0);
        while (true)
        {
          RatingBar localRatingBar = (RatingBar)paramAnonymousView.findViewById(2131493157);
          localRatingBar.setVisibility(0);
          localRatingBar.setRating(Float.parseFloat(paramAnonymousAutoSoftInfo.getHotMark()));
          Button localButton = (Button)paramAnonymousView.findViewById(2131493156);
          localButton.setVisibility(8);
          localButton.setOnClickListener(new View.OnClickListener()
          {
            public void onClick(View paramAnonymous2View)
            {
              RecomedActivity.this.softid = paramAnonymousAutoSoftInfo.getKeyID();
              RecomedActivity.this.btnCurrent = ((Button)paramAnonymous2View);
              new RecomedActivity.DataTask(RecomedActivity.this).execute(new String[] { "softRecd" });
            }
          });
          paramAnonymousView.setOnClickListener(new View.OnClickListener()
          {
            public void onClick(View paramAnonymous2View)
            {
              MarketTabActivity.staASI = paramAnonymousAutoSoftInfo;
              Bundle localBundle = new Bundle();
              localBundle.putString("softName", paramAnonymousAutoSoftInfo.getAsname());
              localBundle.putString("apkname", paramAnonymousAutoSoftInfo.getAspkg());
              localBundle.putString("author", paramAnonymousAutoSoftInfo.getAuthor());
              localBundle.putString("hotMark", paramAnonymousAutoSoftInfo.getHotMark());
              localBundle.putString("softSize", paramAnonymousAutoSoftInfo.getSoftSize());
              localBundle.putString("softType", paramAnonymousAutoSoftInfo.getTypeName());
              localBundle.putString("updateTime", paramAnonymousAutoSoftInfo.getUpdateTime());
              localBundle.putString("downloadurl", paramAnonymousAutoSoftInfo.getAddownloadurl());
              localBundle.putString("icon", paramAnonymousAutoSoftInfo.getAdicon());
              localBundle.putString("keyid", paramAnonymousAutoSoftInfo.getKeyID());
              localBundle.putString("version", paramAnonymousAutoSoftInfo.getVersion());
              localBundle.putString("fromParent", "1");
              localBundle.putInt("isRecd", paramAnonymousAutoSoftInfo.getIsRecd());
              localBundle.putInt("isPrecd", paramAnonymousAutoSoftInfo.getIsPrecd());
              RecomedActivity.this.IntentActivity(RecomedActivity.this, SoftInfoActivity.class, localBundle);
            }
          });
          return paramAnonymousView;
          ((ImageView)paramAnonymousView.findViewById(2131493159)).setVisibility(8);
        }
      }
    });
    this.lvList.setAdapter(this.adapter);
    this.lvList.setOnScrollListener(new AbsListView.OnScrollListener()
    {
      public void onScroll(AbsListView paramAnonymousAbsListView, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3)
      {
      }

      public void onScrollStateChanged(AbsListView paramAnonymousAbsListView, int paramAnonymousInt)
      {
        if ((paramAnonymousInt == 0) && (paramAnonymousAbsListView.getLastVisiblePosition() == -1 + paramAnonymousAbsListView.getCount()) && (!RecomedActivity.this.lvList.getIsNoMore()))
        {
          RecomedActivity.this.lvList.prepareForRefreshMore();
          RecomedActivity.this.isFoot = Boolean.valueOf(true);
          RecomedActivity.this.loadingData(false);
        }
      }
    });
    this.lvList.setOnScrollListener(new AbsListView.OnScrollListener()
    {
      public void onScroll(AbsListView paramAnonymousAbsListView, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3)
      {
      }

      public void onScrollStateChanged(AbsListView paramAnonymousAbsListView, int paramAnonymousInt)
      {
        if ((paramAnonymousInt == 0) && (paramAnonymousAbsListView.getLastVisiblePosition() == -1 + paramAnonymousAbsListView.getCount()) && (!RecomedActivity.this.lvList.getIsNoMore()) && (RecomedActivity.this.blDataTask))
        {
          RecomedActivity.this.lvList.prepareForRefreshMore();
          RecomedActivity.this.isFoot = Boolean.valueOf(true);
          RecomedActivity.this.loadingData(false);
        }
      }
    });
    this.lvList.setOnLoadMoreListener(new PageListView.OnRefreshListener()
    {
      public void onRefresh()
      {
        RecomedActivity.this.lvList.prepareForRefreshMore();
        RecomedActivity.this.isFoot = Boolean.valueOf(true);
        RecomedActivity.this.loadingData(true);
      }
    });
  }

  private void loadingData(boolean paramBoolean)
  {
    if (paramBoolean)
      this.page.firstPage();
    while (true)
    {
      addOperation(new DataTask().execute(new String[] { "installindex" }));
      return;
      this.page.nextPage();
    }
  }

  protected void backKeyCallBack()
  {
    finish();
  }

  public void onBackPressed()
  {
    finish();
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903146);
    initView();
  }

  protected void onResume()
  {
    super.onResume();
    this.page.removeAll();
    this.page.setPageNo(1);
    addOperation(new DataTask().execute(new String[] { "installindex" }));
  }

  class DataTask extends AsyncTask<String, Integer, String>
  {
    String param;

    DataTask()
    {
    }

    protected String doInBackground(String[] paramArrayOfString)
    {
      this.param = paramArrayOfString[0];
      if (this.param.equals("installindex"))
        RecomedActivity.this.events = new RecomSoftServer(RecomedActivity.this).installSoftWare(0, "", "", 1, 0, RecomedActivity.this.page.getPageNo(), RecomedActivity.this.page.getPageSize());
      while (!this.param.equals("softRecd"))
        return null;
      HashMap localHashMap = new HashMap();
      localHashMap.put(RecomedActivity.this.softid, Integer.valueOf(1));
      RqSP localRqSP = new RqSP();
      String str1 = localRqSP.getLgDevAccount(RecomedActivity.this);
      String str2 = localRqSP.getLgDevId(RecomedActivity.this);
      RecomedActivity.this.bean = new RecomSoftServer(RecomedActivity.this).updateRecd(localHashMap, str1, str2);
      return RecomedActivity.this.bean.getDesc();
    }

    protected void onPostExecute(String paramString)
    {
      if (this.param.equals("installindex"))
        if ((RecomedActivity.this.events != null) && (RecomedActivity.this.events.size() > 0))
        {
          RecomedActivity.this.page.addAllEntries(RecomedActivity.this.events);
          RecomedActivity.this.adapter.notifyDataSetChanged();
          RecomedActivity.this.lvList.onLoadMoreComplete();
          if (RecomedActivity.this.events.size() < RecomedActivity.this.page.getPageSize())
          {
            RecomedActivity.this.lvList.hideFotterMoreView();
            RecomedActivity.this.lvList.setIsNoMore(true);
          }
          RecomedActivity.this.events.clear();
          RecomedActivity.this.blDataTask = true;
        }
      while (true)
      {
        if (!RecomedActivity.this.isFoot.booleanValue())
        {
          RecomedActivity.this.closeProgress();
          RecomedActivity.this.isFoot = Boolean.valueOf(false);
        }
        super.onPostExecute(paramString);
        return;
        RecomedActivity.this.lvList.hideFotterMoreView();
        RecomedActivity.this.lvList.setIsNoMore(true);
        break;
        if (this.param.equals("softRecd"))
          if ("0".equals(RecomedActivity.this.bean.getCode()))
          {
            int i = RecomedActivity.this.btnCurrent.getPaddingLeft();
            int j = RecomedActivity.this.btnCurrent.getPaddingTop();
            int k = RecomedActivity.this.btnCurrent.getPaddingRight();
            int m = RecomedActivity.this.btnCurrent.getPaddingBottom();
            RecomedActivity.this.btnCurrent.setText(RecomedActivity.this.getResources().getString(2131427499));
            RecomedActivity.this.btnCurrent.setTextColor(RecomedActivity.this.getResources().getColor(2131230724));
            RecomedActivity.this.btnCurrent.setBackgroundDrawable(RecomedActivity.this.getResources().getDrawable(2130837636));
            RecomedActivity.this.btnCurrent.setPadding(i, j, k, m);
            RecomedActivity.this.alertMessage(RecomedActivity.this.getResources().getString(2131427527));
          }
          else
          {
            RecomedActivity.this.alertMessage(RecomedActivity.this.getResources().getString(2131427528));
          }
      }
    }

    protected void onPreExecute()
    {
      RecomedActivity.this.blDataTask = false;
      if (!RecomedActivity.this.isFoot.booleanValue())
        RecomedActivity.this.showProgress("");
      super.onPreExecute();
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.activity.RecomedActivity
 * JD-Core Version:    0.6.2
 */